﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Windows.Forms;
using System.Xml.XPath;

namespace CustomerEmailer
{
    public class Functions
    {
        public static void GetUsers()
        {
            XPathNavigator nav;
            XPathDocument docNav;
            XPathNodeIterator NodeIter;
            String strExpression;

            // Open the XML.
            docNav = new XPathDocument(string.Format(@"C:\Users\yadid\Documents\My Dropbox\CustomerEmailer\UserDetails.xml"));
            // Create a navigator to query with XPath.
            nav = docNav.CreateNavigator();

            strExpression = "/users/user[group = 1]";
            // Select the node and place the results in an iterator.
            NodeIter = nav.Select(strExpression);
            while (NodeIter.MoveNext())
            {
                MessageBox.Show(string.Format("Book Title: {0}", NodeIter.Current.Value));
            };	




            //XmlDocument xml = new XmlDocument();
            //xml.LoadXml("UserDetails.xml");  // suppose that str string contains "<Names>...</Names>"

            //XmlNodeList xnList = xml.SelectNodes("/users/user[group = 1]");
            //foreach (XmlNode xn in xnList)
            //{
            //    MessageBox.Show(xn.InnerText);
            //}

        }
    }
}
